<template>
  <el-card class="box-card" style="width: 1180px">
    <!-- ----------------------表格--------------------------- -->
    <el-table :data="roleList" border style="width: 100%">
      <el-table-column prop="roleId" label="角色编号" width="180"> </el-table-column>
      <el-table-column prop="roleName" label="角色名称" width="120">
      </el-table-column>      
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" 
            >编辑</el-button
          >
          <el-popconfirm
            title="这是一段内容确定删除吗？"           
          >
            <el-button slot="reference" size="mini" type="danger"
              >删除</el-button
            >
          </el-popconfirm>
          <el-button type="danger" size="mini" @click="assignPermission(scope.row.roleId)"
            >角色分配权限</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
        roleList:[]
    };
  },
  methods: {
    assignPermission(roleId){
        this.$router.push({path:"/Permission",query:{roleId:roleId}});
    },
    loadRoles(){
        this.$axios.get("/roles/").then((res) => {
        this.roleList = res.data.data.roleList;
      });

    }

  },
  mounted(){
    this.loadRoles();
  }
};
</script>